<?php
/**
 * Created by PhpStorm.
 * User: liuxiaojie
 * Date: 2019-02-24
 * Time: 11:43
 */

namespace app\shell\controller;

use app\service\AreaService;
use think\Controller;

class Area extends Controller
{

    function province(){
        $area_serv = new AreaService();
        $data = $area_serv->children();
        if($data){
            $area_serv->updateData($data);

            foreach ($data[0] as $v){
                $children = $area_serv->children($v['id']);
                if($children){
                    $area_serv->updateData($children, $v['id'], 2);
                }
            }
        }


    }

    function county(){

        $list = db('area')->where(['level'=> 2])->column('code');
        foreach ($list as $v){
            $area_serv = new AreaService();
                $county = $area_serv->children($v);
                if($county){
                    $area_serv->updateData($county, $v, 3);

                }

//                exit();
        }

    }

}